(defun loop-n(p m n)
  (let ((res nil))
    (loop for i from m to n do
	 (setf res (dl-append res (dl-list (dl-data (dl-go-next p i))))))
    res))
(defun dl-append(p q)
  (if (null p) q
      (if (null q) p
	  
(if (and (dl-p p) (dl-p q))		     
  (let ((p-end (dl-tail p)))
    (setf p (dl-head (dl-insert (dl-data p-end) q)))
    p)
  (format t "参数错误，不是双向列表。")))))

(defun dl-add-n(p q m n)
  (let ((res nil)(len (length p)))
    (decf m)
    (decf n)
    (if (> m (length p)) (setf m len))
    (if (< m -1) (progn  (setf m (+ len m 1))(if (< m -1) (setf m -1))))
    (setf res (loop-n p 0 m))
    (setf res (dl-append res (loop-n q 0 n)))
    (setf res (dl-append res (loop-n p (1+ m) len)))
    res))

(defun dl-add-nil(p m n)
  (dl-add-n p nil m n))
(defun dl-add(p q m)
  (dl-add-n p (list q) m 1))